package com.yfjin.camera2;

import android.content.Context;

import java.util.List;

import androidx.core.content.res.ResourcesCompat;
import me.weyye.hipermission.HiPermission;
import me.weyye.hipermission.PermissionCallback;
import me.weyye.hipermission.PermissionItem;

/**
 * @author jinyf
 */
public class PermissionUtil {


    public static void simpleAsk(Context context, List<PermissionItem> permissonItems, final Callback callback) {
        if (null == permissonItems || permissonItems.size() == 0) {
            callback.success();
        }

        int color = ResourcesCompat.getColor(context.getResources(), R.color.colorPrimary, context.getTheme());

        HiPermission.create(context)
//                .title(context.getString(R.string.permission_ask_title))
                .permissions(permissonItems)
//                .style(R.style.PermissionStyle)
//                .filterColor(color)
                .checkMutiPermission(new PermissionCallback() {
                    @Override
                    public void onClose() {

                    }

                    @Override
                    public void onFinish() {
                        callback.success();
                    }

                    @Override
                    public void onDeny(String permission, int position) {
                    }

                    @Override
                    public void onGuarantee(String permission, int position) {
                    }
                });
    }

    public interface Callback {
        void success();
    }
}
